package log.jdbc;

import java.sql.Connection ;
import java.sql.DriverManager ;
import java.sql.PreparedStatement ;
import java.sql.ResultSet ;
import java.sql.SQLException ;

public class JDBCUtil {
    public void connDB(){
        String driver = "" ;
        String dbName = "" ;
        String userName = "" ;
        String pwd = "" ;
        
        String url = "" ;
        String sql = "" ;
        
        try {
            Class.forName(driver) ;
            url = url+dbName ;
            Connection conn = DriverManager.getConnection(url,userName,pwd) ;
            PreparedStatement ps = conn.prepareStatement(sql) ;
            ResultSet rs = ps.executeQuery() ;
            //处理rs
            
            if(rs != null){
                try {
                    ps.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            if(ps != null){
                try {
                    conn.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
